<?php


/*
* Copyright (c) 2008-2016 vip.com, All Rights Reserved.
*
* Powered by com.vip.osp.osp-idlc-2.5.11.
*
*/

namespace com\vip\product\model;

class AttrStructForm {
	
	static $_TSPEC;
	public $numberForm = null;
	public $dateForm = null;
	public $layerForm = null;
	
	public function __construct($vals=null){
		
		if (!isset(self::$_TSPEC)){
			
			self::$_TSPEC = array(
			1 => array(
			'var' => 'numberForm'
			),
			2 => array(
			'var' => 'dateForm'
			),
			4 => array(
			'var' => 'layerForm'
			),
			
			);
			
		}
		
		if (is_array($vals)){
			
			
			if (isset($vals['numberForm'])){
				
				$this->numberForm = $vals['numberForm'];
			}
			
			
			if (isset($vals['dateForm'])){
				
				$this->dateForm = $vals['dateForm'];
			}
			
			
			if (isset($vals['layerForm'])){
				
				$this->layerForm = $vals['layerForm'];
			}
			
			
		}
		
	}
	
	
	public function getName(){
		
		return 'AttrStructForm';
	}
	
	public function read($input){
		
		$input->readStructBegin();
		while(true){
			
			$schemeField = $input->readFieldBegin();
			if ($schemeField == null) break;
			$needSkip = true;
			
			
			if ("numberForm" == $schemeField){
				
				$needSkip = false;
				
				$this->numberForm = new \com\vip\product\model\NumberForm();
				$this->numberForm->read($input);
				
			}
			
			
			
			
			if ("dateForm" == $schemeField){
				
				$needSkip = false;
				
				$this->dateForm = new \com\vip\product\model\DateForm();
				$this->dateForm->read($input);
				
			}
			
			
			
			
			if ("layerForm" == $schemeField){
				
				$needSkip = false;
				
				$this->layerForm = new \com\vip\product\model\LayerForm();
				$this->layerForm->read($input);
				
			}
			
			
			
			if($needSkip){
				
				\Osp\Protocol\ProtocolUtil::skip($input);
			}
			
			$input->readFieldEnd();
		}
		
		$input->readStructEnd();
		
		
		
	}
	
	public function write($output){
		
		$xfer = 0;
		$xfer += $output->writeStructBegin();
		
		if($this->numberForm !== null) {
			
			$xfer += $output->writeFieldBegin('numberForm');
			
			if (!is_object($this->numberForm)) {
				
				throw new \Osp\Exception\OspException('Bad type in structure.', \Osp\Exception\OspException::INVALID_DATA);
			}
			
			$xfer += $this->numberForm->write($output);
			
			$xfer += $output->writeFieldEnd();
		}
		
		
		if($this->dateForm !== null) {
			
			$xfer += $output->writeFieldBegin('dateForm');
			
			if (!is_object($this->dateForm)) {
				
				throw new \Osp\Exception\OspException('Bad type in structure.', \Osp\Exception\OspException::INVALID_DATA);
			}
			
			$xfer += $this->dateForm->write($output);
			
			$xfer += $output->writeFieldEnd();
		}
		
		
		if($this->layerForm !== null) {
			
			$xfer += $output->writeFieldBegin('layerForm');
			
			if (!is_object($this->layerForm)) {
				
				throw new \Osp\Exception\OspException('Bad type in structure.', \Osp\Exception\OspException::INVALID_DATA);
			}
			
			$xfer += $this->layerForm->write($output);
			
			$xfer += $output->writeFieldEnd();
		}
		
		
		$xfer += $output->writeFieldStop();
		$xfer += $output->writeStructEnd();
		return $xfer;
	}
	
}

?>